<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <link rel="stylesheet" type="text/css" href="../res/static/css/main.css">
  <link rel="stylesheet" type="text/css" href="../res/layui/css/layui.css">
  <script type="text/javascript" src="../res/layui/layui.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<style type="text/css">
  .layui-input{
    width: 300px;
  }
</style>


</head>
<body>

  <div class="site-nav-bg">
    <div class="site-nav w1200">
      <p class="sn-back-home">
        <i class="layui-icon layui-icon-home"></i>
        <a href="#">首页</a>
      </p>
      <div class="sn-quick-menu">
        <div class="login"><a href="login.html">登录</a></div>
        <div class="sp-cart"><a href="shopcart.html">购物车</a><span>2</span></div>
      </div>
    </div>
  </div>



  <div class="header">
    <div class="headerLayout w1200">
      <div class="headerCon">
        <h1 class="mallLogo">
          <a href="#" title="母婴商城">
            <img src="../res/static/img/fushi.png">
          </a>
        </h1>
        <div class="mallSearch">
          <form action="" class="layui-form" novalidate lay-filter="user">
            <input type="text" name="title" required  lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入需要的商品">
            <button class="layui-btn" lay-submit lay-filter="formDemo">
                <i class="layui-icon layui-icon-search"></i>
            </button>
            <input type="hidden" name="" value="">
          </form>
        </div>
      </div>
    </div>
  </div>


  <div class="content content-nav-base shopcart-content">
    <div class="main-nav">
      <div class="inner-cont0">
        <div class="inner-cont1 w1200">
          <div class="inner-cont2">
            <a href="commodity.html" class="active">所有商品</a>
            <a href="buytoday.html">今日团购</a>
            <a href="information.html">母婴资讯</a>
            <a href="about.html">关于我们</a>
          </div>
        </div>
      </div>
    </div>
   
   <form class="layui-form"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
  <div class="layui-form-item">
    <label class="layui-form-label">头像</label>
    <div class="layui-input-block">
		<img id="face" style="width: 200px;height: 200px;border: 1px solid lightblue" alt="" src="/file/face1.jpg">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">昵称</label>
    <div class="layui-input-inline">
      <input type="text" id="nickname" name="nickname" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">手机号</label>
    <div class="layui-input-inline">
      <input type="text" id="phone" name="phone" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">余额</label>
    <div class="layui-input-inline">
      <input type="text" id="balance" name="balance" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  
  <div class="layui-form-item">
    <label class="layui-form-label">默认收货地址</label>
    <div class="layui-input-inline">
      <input type="text" id="addressId" name="addressId" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
  <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
</form>
<script>
layui.use(['form','jquery'], function(){
  var form = layui.form;
  var $ = layui.jquery;
  
  //因为sessionStorage存储的是字符串类型，所有要用JSON.parse将json字符串转换成json对象
  var user = JSON.parse(sessionStorage.getItem("user"));
  console.log(user)
  
  $.post(
		"../../address/findAddressById.do?id="+user.addressId,
		function(res){
			//console.log(res)
			$("#addressId").val(res.province+res.city+res.detail+""+res.name+""+res.phone)
		},"json"
  );
  
  
  
  //数据回显
   $("#face").attr("src",'/file/'+user.face);
   $("#nickname").val(user.nickname);
   $("#phone").val(user.phone);
   $("#balance").val(user.balance);
   $("#addressId").val(user.addressId);
  
  
  
  //各种基于事件的操作，下面会有进一步介绍
});
</script>
   
    
    
  </div>

<!-- <script type="text/javascript">
  layui.config({
    base: '../res/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
  }).use(['mm','jquery','element','car'],function(){
    var mm = layui.mm,$ = layui.$,element = layui.element,car = layui.car;
    
    // 模版导入数据
    var html = demo.innerHTML,
     listCont = document.getElementById('list-cont');
      mm.request({
       url: "../../shopcart/findCartByUId.do?uid=1",
       success : function(res){
         listCont.innerHTML = mm.renderHtml(html,res)
         element.render();
         car.init()
       },
       error: function(res){
         console.log(res);
      }
     }) 
     
     
     /* $.post(
    	"../../shopcart/findCartByUId.do?uid=1",
    	function(res){
    		//console.log(res)
    		 listCont.innerHTML = mm.renderHtml(html,res)
		      element.render();
		      car.init()
    	},"json"
     ); */
     
     
    car.init()


}); -->
</script>
</body>
</html>